package com.example.icampusevent;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.EditText;

public class LoginListViewAdapter extends BaseAdapter {

	private Activity activity;
	private ArrayList<EditText> editTexts = new ArrayList<EditText>();
	
	public LoginListViewAdapter(Activity activity) {
		this.activity = activity;
	}
	
	public int getCount() {
		return 2;
	}

	public Object getItem(int position) {
		return editTexts.get(position);
	}

	public long getItemId(int position) {
		return 0;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		String hint = null;
		if(convertView == null) {
			 LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			 if(position == 0) hint = "Email";
			 else hint = "Password";
			 vi = inflater.inflate(R.layout.login_listview_row_layout, null);	
			 EditText editText = (EditText)(vi.findViewById(R.id.login_edittext));
			 editText.setHint(hint);
			 editTexts.add(editText);
			 
			 if(editText.getHint().equals("Password")) {
				 editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
			 }
		}

        return vi;
	}

}
